package org.kl.auditsupervision.entity.fnd;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.validator.constraints.NotBlank;
import org.kl.bf.entity.AuditableEntity;
import org.kl.bf.entity.Excel;
import org.kl.bf.utils.BasicConstants;
import org.kl.auditsupervision.entity.fnd.Org;

@Entity
@Table(name = "fnd_post")
public class FndPost extends AuditableEntity {
	private static final long serialVersionUID = 1L;
	@Excel(exportName = "岗位编码")
	private String postNo;
	@Excel(exportName = "岗位名称")
	private String postName;
	@Excel(exportName = "岗位描述")
	private String description;
	@Excel(exportName = "是否启用", exportConvertSign = 1)
	private Integer enable = BasicConstants.NO_INT;
	private String higherPostId;
	@Excel(exportName = "所属组织", exportProperty = "orgName")
	private Org org;
	private FndPost higherPost;

	public FndPost() {
	}

	public FndPost(String id) {
		this.id = id;
	}

	@NotBlank
	public String getPostNo() {
		return postNo;
	}

	public void setPostNo(String postNo) {
		this.postNo = postNo;
	}

	@NotBlank
	public String getPostName() {
		return postName;
	}

	public void setPostName(String postName) {
		this.postName = postName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getEnable() {
		return enable;
	}

	public void setEnable(Integer enable) {
		this.enable = enable;
	}

	public String getHigherPostId() {
		return higherPostId;
	}

	public void setHigherPostId(String higherPostId) {
		this.higherPostId = higherPostId;
	}

	@ManyToOne
	@JoinColumn(name = "org_id")
	public Org getOrg() {
		return org;
	}

	public void setOrg(Org org) {
		this.org = org;
	}

	@Transient
	public FndPost getHigherPost() {
		return higherPost;
	}

	public void setHigherPost(FndPost higherPost) {
		this.higherPost = higherPost;
	}

	@Override
	public String toString() {
		return "Post [postNo=" + postNo + ", postName=" + postName + ", description=" + description + ", enable=" + enable
				+ ", higherPostId=" + higherPostId + ", org=" + org + "]";
	}

	public String enableConvert() {
		return enable == 1 ? "是" : "否";
	}
}